<%-- 
    Document   : file
    Created on : 8 janv. 2014, 11:25:03
    Author     : root
--%>

<%@page import="presenter.Presenter"%>
<%@page import="java.util.Map.Entry"%>
<%@page import="java.util.Map"%>
<%@page import="java.util.HashMap"%>
<%@page import="java.util.ArrayList"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<% HttpSession thisSession = (HttpSession) request.getAttribute("thisSession");
    String demande = "";
    String name = "";
    String fichier = "";
    ArrayList<String> demandeContact = (ArrayList<String>) thisSession.getAttribute("demandeContact");
    String msgFile = "";
    Map<String, String> waitingFile = (HashMap<String, String>) request.getAttribute("waitingFile");
    Map<String, String> file = (HashMap<String, String>) request.getAttribute("file");
    if (waitingFile.size() > 0) {
        msgFile = msgFile + "(" + waitingFile.size() + ")";

    }
    if (demandeContact.size() != 0) {
        boolean accept = true;
        int notif = demandeContact.size();
        if (notif != 0) {
            demande = " (" + notif + ")";
        }
    }
    ArrayList<String> newMessage = (ArrayList<String>) thisSession.getAttribute("newMessage");
    String newMsg = "";
    if (newMessage.size() != 0) {
        newMsg = newMsg + " (" + newMessage.size() + ")";
    }

    Presenter.setDownloaded((String) thisSession.getAttribute("login"));
%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <link rel="stylesheet" type="text/css" href="css/connected.css"/>
        <title>Files</title>
    </head>
    <body>
        <header>
            <a href="RedirectConnected"><img src="Pictures/logo.png" class="logo" style="float: outside;"></a>
            <div class="zone">
                <div class="zone-right"></div>
                <div class="zone-left"></div>
                <div class="zone-bg">
                    <ul>
                        <li><a href="RedirectConnected"><span>Home <%= newMsg%></span></a></li>
                        <li><a href="NewContact.html"><span>Contact <%= demande%></span></a></li>
                        <li><a href="profile.html"><span>Profile</span></a></li>
                        <li class="current"><a href="File.html"><span>File <%= msgFile%></span></a></li>
                        <li><a href="Administrator.html"><span>Administration</span></a></li>
                        <li><a href="logout.html"><span>Logout</span></a></li>
                    </ul>
                </div>
            </div>
        </header>

        <img src="Pictures/file.png" class="imgfile">
        <% if (waitingFile.size() != 0) {%>
        You have waiting file(s) : <br>
        <%  for (Entry<String, String> entry : waitingFile.entrySet()) {
                fichier = entry.getKey();
                name = entry.getValue();
        %>
        <%= name%> : <% out.println("<a href=\"FileDownload?fileName=" + fichier + "\"> " + fichier + "</a><br>"); %>
        <%  }

        } else {%>
        <br> No file.
        <% }
        %>

        <% if (file.size() != 0) { %>
        <br> Your file(s) : <br>
        <%  for (Entry<String, String> entry : file.entrySet()) {
                fichier = entry.getKey();
                name = entry.getValue();
        %>
        <%= name%> : <% out.println("<a href=\"FileDownload?fileName=" + fichier + "\"> " + fichier + "</a><br>"); %>
        <%  }
            }
        %>
    </body>
</html>
